<?php
function friends_lister() {
include("processing/global-settings.php");
$userid = $_SESSION['userid'];
mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: " . mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$results = mysql_query("SELECT * FROM requests WHERE RequestRecipientID = '$userid'");
while($row = mysql_fetch_array($results)) {
	echo $row['RequestRecipientID'];
	echo "<br>";
?>
	<input name="accept" type="submit" value="Accept" />
	<input name="deny" type="submit" value="Deny" />
<?php
	echo "<br>";
}
}
function connection_handler() {
include("../processing/global-settings.php");

mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: " . mysql_error());
mysql_select_db($dbname) or die(mysql_error());

if(isset($_POST['accept'])) {
mysql_query("INSERT IGNORE INTO requests (RequestSentByID, RequestRecipientID, RequestStatus, AddedMessage, FriendType)
VALUES(1, '$userid_generator', 'Accepted', 'Welcome to Druvla', 'full')")or die(mysql_error());
mysql_query("INSERT INTO users (UserID, username, password, first_name, last_name, email_address)
VALUES('$userid_generator', '$username', '$password', '$first_name', '$last_name', '$email')")or die(mysql_error());
}
} // end if isset
if(isset($_POST['deny'])) {
mysql_query("INSERT IGNORE INTO requests (RequestSentByID, RequestRecipientID, RequestStatus, AddedMessage, FriendType)
VALUES(1, '$userid_generator', 'Denied', 'Welcome to Druvla', 'full')")or die(mysql_error());
mysql_query("INSERT INTO users (UserID, username, password, first_name, last_name, email_address)
VALUES('$userid_generator', '$username', '$password', '$first_name', '$last_name', '$email')")or die(mysql_error());
}
?>